Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileCleanup Improvements #633

Merged
merged 27 commits into from
Dec 21, 2024
Merged

FileCleanup Improvements #633

merged 27 commits into from
Dec 21, 2024

Conversation

bagusnl
Copy link
Member

@bagusnl bagusnl commented Dec 20, 2024

Main Goal

Improve FileCleanup logics for items > 1000 as before it froze the UI completely

  1. Use SelectAllSafe and UnselectAll to do as described

Improved speed when selecting all items by (from ~140000 ms to ~170ms) when selecting 25000 files.

  1. Use .NET's built-in SIMD calculation for summing all the asset sizes
  2. Use batching when injecting files to the ListViewTable source

PR Status :

  • Overall Status : Done
  • Commits : Done
  • Synced to base (Collapse:main) : Yes
  • Build status : OK
  • Crashing : No
  • Bug found caused by PR : 0

bagusnl and others added 14 commits August 4, 2024 17:41
# Main Goal
{Describe/list your goal for the PR here}

## PR Status :
- Overall Status : Done/In Progress/Stalled/Cancelled
- Commits : Done/In Progress/Stalled/Cancelled
- Synced to base (Collapse:main) : Yes/Not yet
- Build status : OK/Crashing/Build Errors
- Crashing : Yes/No
- Bug found caused by PR : {int}

### Templates

<details>
  <summary>Changelog Prefixes</summary>
  
  ```
    **[New]**
    **[Imp]**
    **[Fix]**
    **[Loc]**
    **[Doc]**
  ```

</details>
InjectFileSource
1. Increase possible batch size
2. Use Interlock.Increment

Delete to Recycle Bin
1. Improve FileInfoSource removal speed
…lecleanup-improvement"

This reverts commit 474422f, reversing
changes made to 32c6cae.
@bagusnl bagusnl added Enhancement New feature or request Area: Runtime Issue labeled for runtime, Hi3Helper.Core and other libraries used by Collapse Priority: Medium labels Dec 20, 2024
@bagusnl bagusnl self-assigned this Dec 20, 2024
Copy link

Qodana for .NET

1 new problem were found

Inspection name Severity Problems
Redundant using directive 🔶 Warning 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Detected 67 dependencies

Third-party software list

This page lists the third-party software dependencies used in CollapseLauncher

Dependency Version Licenses
CommunityToolkit.Common 8.4.0 MIT
CommunityToolkit.Mvvm 8.4.0 MIT
CommunityToolkit.WinUI.Animations 8.2.241112-preview1 MIT
CommunityToolkit.WinUI.Behaviors 8.2.241112-preview1 MIT
CommunityToolkit.WinUI.Controls.Primitives 8.2.241112-preview1 MIT
CommunityToolkit.WinUI.Controls.Sizers 8.2.241112-preview1 MIT
CommunityToolkit.WinUI.Converters 8.2.241112-preview1 MIT
CommunityToolkit.WinUI.Extensions 8.2.241112-preview1 MIT
CommunityToolkit.WinUI.Helpers 8.2.241112-preview1 MIT
CommunityToolkit.WinUI.Media 8.2.241112-preview1 MIT
CommunityToolkit.WinUI.Triggers 8.2.241112-preview1 MIT
Costura.Fody 6.0.0 MIT
DotNet.ReproducibleBuilds 1.2.25 MIT
EventGenerator.Generator 0.13.1 MIT
Fody 6.9.1 MIT
GitInfo 3.5.0 MIT
Google.Protobuf.Tools 3.29.1 PROTOBUF
Google.Protobuf 3.29.1 BSD-3-Clause
Hi3Helper.ZstdNet 1.6.3 BSD-3-Clause
HtmlAgilityPack 1.11.71 MIT
Markdig.Signed 0.38.0 BSD-2-Clause
Microsoft.CSharp 4.7.0 MIT
Microsoft.Extensions.DependencyInjection.Abstractions 9.0.0 MIT
Microsoft.Extensions.DependencyInjection 9.0.0 MIT
Microsoft.Extensions.Logging.Abstractions 9.0.0 MIT
Microsoft.Extensions.Logging 9.0.0 MIT
Microsoft.Extensions.Options 9.0.0 MIT
Microsoft.Extensions.Primitives 9.0.0 MIT
Microsoft.Graphics.Win2D 1.3.0 MS-ASP-NET-WEB-OPTIMIZATION
Microsoft.NET.ILLink.Tasks 9.0.0 MIT
Microsoft.NETCore.Targets 6.0.0-preview.4.21253.7 MIT
Microsoft.Web.WebView2 1.0.2950-prerelease BSD-3-Clause
BSD-MYLEX
Microsoft.Win32.SystemEvents 9.0.0 MIT
Microsoft.Windows.CsWin32 0.3.106 Apache-2.0
Microsoft.Windows.CsWinRT 2.2.0 MIT
Microsoft.Windows.SDK.BuildTools 10.0.26100.1742 PROPRIETARY-LICENSE
Microsoft.Windows.SDK.Win32Docs 0.1.42-alpha PROPRIETARY-LICENSE
Microsoft.Windows.SDK.Win32Metadata 60.0.34-preview MIT
Microsoft.Windows.WDK.Win32Metadata 0.11.4-experimental MIT
Microsoft.WindowsAppSDK 1.6.241114003 MIT
MS-DXSDK-D3DX-9.29.952.3
Microsoft.Xaml.Behaviors.WinUI.Managed 2.0.9 MIT
MinVer 6.0.0 Apache-2.0
NuGet.Versioning 6.12.1 Apache-2.0
PhotoSauce.MagicScaler 0.15.0 MIT
PhotoSauce.NativeCodecs.Libwebp 1.4.0-preview1 MIT
Roman-Numerals 2.0.1 MIT
Sentry 4.13.0 MIT
SharpCompress 0.38.0 MIT
SharpHDiffPatch.Core 2.2.8 MIT
System.Drawing.Common 9.0.0 MIT
System.IO.Hashing 9.0.0 MIT
System.Net.Http 4.3.4 MIT
System.Security.AccessControl 6.0.1 MIT
System.Security.Cryptography.Algorithms 4.3.0 MIT
System.Security.Cryptography.Encoding 4.3.0 MIT
System.Security.Cryptography.Primitives 4.3.0 MIT
System.Security.Cryptography.ProtectedData 9.0.0 MIT
System.Security.Cryptography.X509Certificates 4.3.0 MIT
System.Text.Encoding.CodePages 9.0.0 MIT
System.Text.Json 9.0.0 MIT
System.Text.RegularExpressions 4.3.1 MIT
System.Threading.Tasks.Extensions 4.5.4 MIT
TaskScheduler 2.11.0 MIT
ThisAssembly.Constants 2.0.6 MIT
Velopack 0.0.942 MIT
ZstdSharp.Port 0.8.1 MIT
runtime.win-x64.Microsoft.DotNet.ILCompiler 9.0.0 MIT
Contact Qodana team

Contact us at [email protected]

using System.IO;
using System.Linq;
using System.Numerics;

Check warning

Code scanning / QDNET

Redundant using directive Warning

Using directive is not required by the code and can be safely removed
@bagusnl bagusnl requested a review from a team December 20, 2024 14:49
@@ -220,9 +344,10 @@ private async Task PerformRemoval(ICollection<LocalFileInfo>? deletionSource, lo
await Task.Run(() => RecycleBin.MoveFileToRecycleBin(toBeDeleted));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do it in parallel as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For recycle bin there is no need. It passes the list of files to be deleted to Windows default "Move to recycle bin" method then delete it that way

neon-nyan and others added 5 commits December 21, 2024 20:09
1. Use backedFileInfoSourceList on  InjectFileSource so its faster
2. Remove unnecesary iteration on InjectFileSource
3. Use thread*4 when deleting items
Co-Authored-By: Bagus Nur Listiyono <[email protected]>
+ Initialize deletion file task to fully async with its own thread
+ Log deletion performance
+ Pass _assetTotalSize to the injector method instead of the constructor
@bagusnl
Copy link
Member Author

bagusnl commented Dec 21, 2024

PR finished, merging manually due to submodule merge conflict

@bagusnl bagusnl merged commit 019685f into main Dec 21, 2024
1 of 2 checks passed
@Cryotechnic Cryotechnic deleted the filecleanup-improvement branch December 22, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Runtime Issue labeled for runtime, Hi3Helper.Core and other libraries used by Collapse Enhancement New feature or request Priority: Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants